
using System;
using System.Collections;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
 // ERROR: Not supported in C#: OptionDeclaration
namespace NCS_CS
{
	internal class CCard6208
	{
		const int cardType = DASK.PCI_6208V;
		short card;
		//Dim errmsg As String
		public bool islinked;
		public event myErrEventHandler myErr;
		public delegate void myErrEventHandler(int num, string des);
		public void link()
		{
			try {
				if (!ModMain.program1.demo) {
					card = DASK.Register_Card(cardType, 0);
				}
				if (card < 0) {
					modLog.savelogmsg("register card failed.");
				} else {
					islinked = true;
				}
				return;
			} catch (System.Exception e) {
				islinked = false;
				if (myErr != null) {
					myErr(1, "can not link card!");
				}
				modLog.savelogmsg("card init ");
				modLog.savelogmsg(e.ToString()); 
			}
		}
		public void unLink()
		{
			try {
				int result = 0;
				if (!ModMain.program1.demo) {
					if (card >= 0) {
						result = DASK.Release_Card(card);
					}
					System.Environment.Exit(0);
				}
				return;
			} catch (System.Exception e) {
				modLog.savelogmsg(e.ToString()); 
			}
		}
		public void newDA(int chanel, double v)
		{
			if (!ModMain.program1.demo) {
				DASK.AO_VWriteChannel(card, (short)chanel, v);
			}
		}
	}
}
